package com.chenjj.scala.oo

/**
  * 伴生类
  */
class Markers  private (val color:String) {
  println("Creating " + this)
  override def toString: String = {
    "marker color " + color
  }
}

object Markers {
  private val marks = Map("red" -> new Markers("red"),
                                               "blue" -> new Markers("blue"))

   def getMarker(color:String) = {
     if (marks.contains(color)){
       marks(color)
     }else{
       null
     }
   }
}


